
lst = [10, 98, 55, 78, 98, 66, 87, 2, 12]
#从小到大排序
# 插入排序
for i in range(1,len(lst)):
    m = i
    for j in range(i-1, -1, -1):
        if lst[i] < lst[j]:
            m = j
        else:
            break
    lst.insert(m, lst[i])
    lst.pop(i+1)

print(lst)





# for i in range(len(lst)):
#     a = lst[i]
#     j = i-1
#     while (j>= 0 and a<lst[j]):
#         lst[j+1] = lst[j]
#         j -= 1
#         lst[j+1] = a
#
# print(lst)


# 冒泡排序
# for i in range(len(lst)-1):
#     for j in range(len(lst)-i-1):
#         if lst[j] > lst[j+1]:
#             lst[j],lst[j+1] = lst[j+1],lst[j]
#
# print(lst)

# # 选择排序
# for i in range(len(lst)):
#     a = i
#     for j in range(i+1,len(lst)):
#         if lst[a] > lst[j]:
#             a = j
#
#     lst[i],lst[a] = lst[a],lst[i]
# print(lst)



# a = []
# i = 0
# while i < len(lst):
#     small = lst[0]
#     for j in range(1, len(lst)):
#         if small > lst[j]:
#             small = lst[j]
#     a.append(small)
#     lst.remove(small)
# print(a)
